<template>
  <el-dialog title="发货确认" width="25%" :visible.sync="visible">
    <el-form ref="form" :model="form" dialog-form label-position="right" label-width="120px">
      <el-form-item label="车牌号" prop="license" :rules="self.page.rules.def">
        <form-upload-image v-model="form.license" size="mini" :remote="self.upload.img" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="mini" @click="visible = false">取 消</el-button>
      <el-button size="mini" type="primary" @click="submit">提交</el-button>
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: 'PurChecking',
  props: {
    value: {
      type: String,
      default: ''
    },
    self: {
      type: Object,
      default: () => { return {} }
    }
  },
  data() {
    return {
      visible: false,
      form: {
        info: ''
      }
    }
  },
  created() {

  },
  methods: {
    show() {
      this.visible = true
    },
    submit() {
      const that = this
      that.form.id = that.value
      that.$refs['form'].validate((valid) => {
        if (!valid) {
          return
        }
        const loading = that.$loading()
        const url = that.self.page.router.remoteUrl + '/checking'
        that.self.service.post(url, { id: that.form.id, message: '', params: { license: that.form.license, photo: that.form.license }}).then(res => {
          loading.close()
          if (res.code !== 200) {
            that.$message.error(res.message)
            return
          }
          that.$message.success('操作成功!')
          that.self.reload(true)
        }).catch((e) => {
          loading.close()
        })
      })
    }
  }
}
</script>
